package day2;

import java.time.Year;
import java.util.Scanner;

import org.junit.Test;

public class SwichTest {

	public static void main(String[] args){
		long y = 0x123l;
		System.out.println(y);
//		for(int i = 0;i <= 3;i++){
//		    switch(i){
//		        case 1:
//		            System.out.println("a");
//		            break;
//		        case 0:
//		            System.out.println("b");
//		            break;
//		        default:
//		            System.out.println("c");
//		            break;
//		        case 2:
//		            System.out.println("d");
//		        }
//		   
//		}
		
	}
	//switch选择示例
	@Test
	public void test1() {
		int num = 2;
		switch (num) {
		case 1:
			System.out.println("1");
			break;
		case 2:
			System.out.println("2");
			break;
		case 3:
			System.out.println("3");
			break;

		default:
			System.out.println("滚");
			break;
		}
	}
	
	
	//输入月份判断天数
	@Test
	public void test2() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入月份：");
		int month = scanner.nextInt();
		
		switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			System.out.println("该月份有31天");
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			System.out.println("该月份有30天");
			break;
		case 2:
			System.out.println("请输入年份：");
			int Year = scanner.nextInt();
			if ((Year % 4 == 0 && Year % 100 != 0 )||(Year % 400 == 0)) {
				System.out.println("该月有29天");
			}else {
				System.out.println("该月有28天");
			}
			break;
		default:
			System.out.println("输入月份错误");
			break;
		}
	}
	
	
	//输入成绩判断等级
	@Test
	public void test4() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入该生成绩");
		int score = scanner.nextInt();
		if (score > 100) {
			System.out.println("输入错误");
		}
		score = score / 10;
		
		switch (score) {
		case 10:
		case 9:
			System.out.println("该生成绩优秀");
			break;
		case 8:
			System.out.println("该生成绩良好");
			break;
		case 7:
			System.out.println("该生成绩一般");
			break;
		case 6:
			System.out.println("该生成绩及格");
			break;	
		case 5:
		case 4:
		case 3:
		case 2:
		case 1:
		case 0:
			System.out.println("不及格");
			break;
		default:
			System.out.println("该生前途无量");
			break;
			
		}
		
	}
	
	
	//break 和 continue实例
	@Test
	public void test5() {
		
		for (int i = 1; i <= 5; i++) {
			if (i == 3) {
				continue;
			}
			System.out.println(i);
		}
		System.out.println("--------------");
		for (int i = 1; i <= 5; i++) {
			if (i == 3) {
				break;
			}
			System.out.println(i);
		}
		System.out.println("--------------");
		for (int i = 1; i <= 5; i++) {
			for (int j = 1; j <= 5; j++) {
				if (j == 3) {
					break;//break只能退出离他最近的那一层循环
				}
				System.out.print(j + " ");
			}
		}
	}
}
